﻿ <!--#include file="inc/common.asp" -->

 <%
  if userObj.userId=""  then
    call assertConnected()
    call closeDb()  
    response.clear
    response.redirect("login.asp?blog_id=" & blogObj.blogId & "&cat_id=" & blogCatObj.catId )
    response.end
  end if
  
  if USER_REGISTER_BLOG=false then
  	 message("暂未开放blog申请")
  end if
  
  call openDB()
    
  if request("actionType")="register" then
     dim  blog_id, blog_title, blog_desc, user_id, user_name
        user_name = userObj.userName
        
        blog_title = request("blog_title")
        blog_desc = request("blog_desc")
        
        user_id=userObj.userId
        
        sql = " select * from blog where blog_id<>1 and user_id=" & user_id
        rs.open sql, conn, 1, 3
        if not rs.eof  then
            'response.write(user_name & "已经拥有blog，id="&rs("blog_id"))
        else
            rs.addNew()
            rs("blog_title")=blog_title
            rs("blog_desc")=blog_desc
            rs("user_id")=user_id
            rs("user_name")=user_name
            rs("photo_url")="photo/t1.gif"
            rs("page_size")=6
            rs.update()
        
            conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 1, '管理员', '管理员', true, true, true, true, true, true) ")
            conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 2, '好友', '好友', true, true, true, true, false, false) ")
            conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 3, '注册网友', '注册网友', true, true, false, false, false, false) ")
            conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 4, '匿名网友', '匿名网友', true, true, false, false, false, false) ")
            conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 5, '黑名单', '黑名单', false, false, false, false, false, false) ")
        
            dim mlHost
            set mlHost = new MLHostClass   
            mlHost.reload()                  

			userObj.reload(userObj.userName)
        
        
        end if

        dim succ_msg, blog_url
        succ_msg = "Blog注册成功，访问地址："
        blog_url = baseURL & "/?blog_id=" & rs("blog_id")
		succ_msg = succ_msg & "<a href='" & blog_url & "'>" & blog_url & "</a>或"
        blog_url = baseURL & "/?user=" & rs("user_name")
		succ_msg = succ_msg & "<a href='" & blog_url & "'>" & blog_url & "</a>"

        rs.close()
      
        message(succ_msg)
        response.end
    end if
 %>
 <HTML><HEAD><TITLE><%=blogObj.blogTitle%></TITLE>
<META http-equiv=Content-Type content="text/html; charset=<%=DEFAULT_CHARSET%>">

<style type="text/css">
TD{
    font-size:x-small;
    color:#333333;letter-spacing : 1pt ;line-height :14pt
}

INPUT {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
SELECT {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
TEXTAREA {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
BUTTON {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px solid; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}

</style>
<script language=javascript>
function selectFace(){
    window.open("select_face.asp","select_fase","width=300px,height=400px,resizable,scrollbars");
}
</script>
</HEAD>
<BODY bgProperties=fixed topMargin=2 bgcolor=white onload="">
   <br><br>
   <form name=form1 action=reg_blog.asp method=post>   
        <table width=450px border=1 cellspacing=0 cellpadding=4 bordercolordark=#FFFFFF bordercolorlight=#98ccd0  bordercolor=#98ccd0 align=center >
          <tr  bgcolor=#98ccd0 >
            <td align=center nowrap height=40px  colspan=2>-->> .::.::: <b>Blog注册</b>  :::.::. <<-- </td>       
          </tr>
          <tr> 
           <td nowrap>
           Blog标题:
            </td>   
           <td>
           <input type=input name=blog_title size=15 value="" > <font color=red>*</font>
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           Blog描述：<br><i>不能超过 300 个字符 </i>
            </td>   
           <td>
           <textarea name=blog_desc cols=40 rows=4></textarea> 
            </td>   
          </tr>                                                                                 
          <tr  bgcolor=#98ccd0 > 
           <td colspan=2>
            &nbsp;
            </td>   
          </tr>                                                                                 
          <tr>                                                                              
            <td align=center height=40px colspan=2  >  
               <input type=button value=' 注册 ' onclick="form1.submit()"> 
               <input type=button onclick='history.back()' value=' 后退 '> 
               <input type=button onclick='document.location="index.asp?blog_id=<%=blogObj.blogId%>&cat_id=<%=blogCatObj.catId%>&pageno=<%=request("pageno")%>"' value=' 返回 '> 
            </td>
          </tr>
        </table>

        <input type=hidden name=blog_id value=<%=blogObj.blogId%> >
        <input type=hidden name=cat_id value=<%=blogCatObj.catId%> >
        <input type=hidden name=pageno value=<%=request("pageno")%> >


        <input type=hidden name=actionType value="register" >
    </form>
</BODY>


</HTML>

<!--#include file="inc/end.asp" -->